<!--#include file="lib/utf-8.asp"-->
<!--#include file="lib/conn.asp"-->
<!--#include file="lib/saferequest.asp"-->
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; chars_workorderet=utf-8" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="Expires" content="-1" />
<link type="text/css" rel="stylesheet" href="lib/jquery_ui_lastest/themes/base/jquery_ui_lastest.css" />
<link type="text/css" rel="stylesheet" href="lib/sheet.css" />
<script type="text/javascript" src="lib/jquery_lastest.js"></script>
<script type="text/javascript" src="lib/jquery_timers_workorder_lastest.js"></script>
<script type="text/javascript" src="lib/jquery_ui_lastest/jquery_ui_lastest.js"></script>
<script type="text/javascript" src="lib/main.js"></script>
<style type="text/css">
#gallery { float: left; width: 65%; min-height: 12em; } * html #gallery { height: 12em; } /* IE6 */
.gallery.custom-state-active { background: #eee; }
.gallery li { float: left; width: 7em; height: 9.5em; padding: 0.4em; margin: 0 0.4em 0.4em 0; text-align: center; }
.gallery li.double { width: 15.35em; }
.gallery li h5 { margin: 0 0 0.4em; cursor: move;}
.gallery li h5.ui-widget-header { height: 2.8em;}
.gallery li a { float: right; }
.gallery li a.ui-icon-zoomin { float: left; }
.gallery li img { width: 100%; cursor: move; }

#trash { float: right; width: 32%; min-height: 18em; padding: 1%;} * html #trash { height: 18em; } /* IE6 */
#trash h4 { line-height: 16px; margin: 0 0 0.4em; }
#trash h4 .ui-icon { float: left; }
#trash .gallery h5 { display: none; }

#workorderlist{ float: left; min-height: 12em; max-height: 50em; overflow:auto; }
#trucklist{ float: right; min-height: 12em; max-height: 50em; overflow:auto; }
.truck{ width: 16.8em; height: 13em; margin:0 20px 1em 0; padding: 1%;}
.truck h4 { margin: 0 0 0.4em; }
</style>
<script type="text/javascript">
	$(function() {
		function fitWindowHeight(){
			var h=$(window).height();
			//alert(h);
			h=h-30;
			return h;
		}
		function fitDocumentWidth(n){
			var w=$(document).width();
			//alert(h);
			w=w-n-50;
			return w;
		}
		$("#workorderlist").height(fitWindowHeight());
		//alert($("#trucklist").width());
		$("#workorderlist").width(fitDocumentWidth($(".truck").width()));
		$("#trucklist").height(fitWindowHeight());
		$(".truck").click(function(){
			$(".truck").removeClass("ui-state-highlight");
			$(this).toggleClass("ui-state-highlight");
		});
		
		$.getJSON("NotDispatchWorkOrder.asp",function(data){
			order="";
			$.each(data,function(i,item){
				order+='<li class="ui-widget-content ui-corner-tr">'
				order+='<h5 class="ui-widget-header">'+item.customer_name+'</h5>'
				order+='<h5>'+item.dd+'&nbsp;'+item.xx+'</h5>'
				order+='<h5>'+item.tx+'&nbsp;'+item.hx+'</h5>'
				order+='<h5>'+item.rq+'&nbsp;'+item.sj+'</h5>'
				order+='<a href="images/high_tatras.jpg" title="查看详细工单" class="ui-icon ui-icon-zoomin">查看</a>'
				order+='<a href="link/to/trash/script/when/we/have/js/off" title="派工单到承运车辆" class="ui-icon ui-icon-check">派单</a>'
				order+='</li>'
			});
			//$("#workorderlist").html(order);
		});
			$( "li", $( "#workorderlist" ) ).draggable({
				cancel: "a.ui-icon", // clicking an icon won't initiate dragging
				revert: "invalid", // when not dropped, the item will revert back to its initial position
				containment: $( "#demo-frame" ).length ? "#demo-frame" : "document", // stick to demo-frame if present
				helper: "clone",
				cursor: "move"
			});
			$( "#workorderlist" ).droppable({
				accept: ".ui-state-highlight",
				activeClass: "custom-state-active",
				drop: function( event, ui ) {
					recycleImage( ui.draggable );
				}
			});
			$( ".truck .ui-state-highlight" ).droppable({
				accept: "#workorderlist > li",
				activeClass: "ui-state-highlight",
				drop: function( event, ui ) {
					deleteImage( ui.draggable );
				}
			});
			var close_icon = "<a href='link/to/recycle/script/when/we/have/js/off' title='取消派工单' class='ui-icon ui-icon-close'>取消</a>";
			function deleteImage( $item ) {
				$item.fadeOut(function() {
					var $list = $( "ul", $( ".ui-state-highlight" ) ).length ?
						$( "ul", $( ".ui-state-highlight" ) ) :
						$( "<ul class='gallery ui-helper-reset'/>" ).appendTo( $( ".ui-state-highlight" ) );

					$item.find( "a.ui-icon-check" ).remove();
					$item.append( close_icon ).appendTo( $list ).fadeIn(function() {
						//$item
							//.animate({ width: "48px" })
							//.find( "img" )
							//	.animate({ height: "36px" });
					});
				});
			}
			var check_icon = "<a href='link/to/trash/script/when/we/have/js/off' title='派工单到承运车辆' class='ui-icon ui-icon-check'>派单</a>";
			function recycleImage( $item ) {
				$item.fadeOut(function() {
					$item
						.find( "a.ui-icon-close" )
							.remove()
						.end()
						//.css( "width", "96px")
						.append( check_icon )
						//.find( "img" )
						//	.css( "height", "72px" )
						//.end()
						.appendTo( $( "#workorderlist" ) )
						.fadeIn();
				});
			}
			function viewLargerImage( $link ) {
				var src = $link.attr( "href" ),
					title = $link.siblings( "img" ).attr( "alt" ),
					$modal = $( "img[src$='" + src + "']" );

				if ( $modal.length ) {
					$modal.dialog( "open" );
				} else {
					var img = $( "<img alt='" + title + "' width='384' height='288' style='display: none; padding: 8px;' />" )
						.attr( "src", src ).appendTo( "body" );
					setTimeout(function() {
						img.dialog({
							title: title,
							width: 400,
							modal: true
						});
					}, 1 );
				}
			}
			$( "ul.gallery > li" ).click(function( event ) {
				var $item = $( this ),
					$target = $( event.target );

				if ( $target.is( "a.ui-icon-check" ) ) {
					deleteImage( $item );
				} else if ( $target.is( "a.ui-icon-zoomin" ) ) {
					viewLargerImage( $target );
				} else if ( $target.is( "a.ui-icon-close" ) ) {
					recycleImage( $item );
				}

				return false;
			});


		
	});
</script>
</head>
<%
Call CheckRights(2,4)
%>

<body>
<div class="ui-widget ui-helper-clearfix">
	<ul id="workorderlist" class="gallery ui-helper-reset ui-helper-clearfix">
	<%
		Set rs_workorder = Server.CreateObject("ADODB.Recordset")
		sql="SELECT id,RIGHT(rq,LEN(rq)-5) AS rq,LEFT(sj,LEN(sj)-3) AS sj,dd,LEFT(customer_name,12) as customer_name,tx,hx,xx,teu FROM (SELECT id,rq,sj,dd,yb_customer,tx,hx,xx,INT(xx/20) AS teu FROM yb WHERE cyr=0) AS yb LEFT JOIN customer ON yb.yb_customer=customer.customer_id WHERE rq>=DATE()-1 ORDER BY rq DESC,sj ASC "
		rs_workorder.Open sql,conn,1,1
		do while not rs_workorder.eof
	%>
		<li class="ui-widget-content <%if rs_workorder("teu")=2 then response.write("double")%>">
			<h5 class="ui-widget-header"><%=rs_workorder("customer_name")%></h5>
			<h5><%=rs_workorder("dd")%>&nbsp;<%=rs_workorder("xx")%></h5>
			<h5><%=rs_workorder("tx")%>&nbsp;<%=rs_workorder("hx")%></h5>
			<h5><%=rs_workorder("rq")%>&nbsp;<%=rs_workorder("sj")%></h5>
			<a href="images/high_tatras.jpg" title="查看详细工单" class="ui-icon ui-icon-zoomin">查看</a>
			<a href="link/to/trash/script/when/we/have/js/off" title="派工单到承运车辆" class="ui-icon ui-icon-check">派单</a>
		</li>
	<%
			rs_workorder.movenext
		loop
		rs_workorder.close
		set rs_workorder=nothing
	%>
	</ul>
	<div id="trucklist" class="ui-widget ui-helper-clearfix">
	<%
		Set rs_truck = Server.CreateObject("ADODB.Recordset")
		sql="select clid,clm,cph,tel,cdm from cl left join cd on cl.sscd=cd.cdid order by cdm,cph"
		rs_truck.Open sql,conn,1,1
		do while not rs_truck.eof
	%>
		<div class="truck ui-widget-content ui-state-default">
			<h4 class="ui-widget-header"><%=rs_truck("cph")%>&nbsp;<%=rs_truck("clm")%></h4>
		</div>
	<%
			rs_truck.movenext
		loop
		rs_truck.close
		set rs_truck=nothing
		conn.close
		set conn=nothing
	%>
	</div>


</div><!-- End demo -->

</body>
</html>
